package com.example.springcloud.controller;


import com.example.springcloud.pojo.User;
import com.example.springcloud.service.UserClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class UserConsumerController {
//    理解：消费者没有service层
//    RestTemplate，供我们直接调用就可以了
//    (url, 尸体：Map,Class<T> responseType)

    @Autowired
    private UserClientService userClientService = null;

    @RequestMapping("/consumer/user/add")
    public boolean add(User user){
        return this.userClientService.addUser(user);
    }

    @RequestMapping("/consumer/user/get/{id}")
    public User get(@PathVariable("id") Long id){
        return this.userClientService.queryById(id);
    }


    @RequestMapping("/consumer/user/list")
    public List<User> list(){
        return this.userClientService.queryAll();
    }
}
